package com.code.petapp.util;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.util.Log;

import com.code.petapp.R;
import com.luck.picture.lib.animators.AnimationType;
import com.luck.picture.lib.basic.PictureSelector;
import com.luck.picture.lib.config.PictureMimeType;
import com.luck.picture.lib.config.SelectMimeType;
import com.luck.picture.lib.config.SelectModeConfig;
import com.luck.picture.lib.entity.LocalMedia;
import com.luck.picture.lib.interfaces.OnResultCallbackListener;
import com.luck.picture.lib.style.PictureSelectorStyle;
import com.luck.picture.lib.style.PictureWindowAnimationStyle;

public class MediaUtils {
    public static void getPhoto(Activity activity, int max, OnResultCallbackListener<LocalMedia> request) {
        PictureWindowAnimationStyle mWindowAnimationStyle = new PictureWindowAnimationStyle();
        mWindowAnimationStyle.activityEnterAnimation = R.anim.bottom_dialog_in;
        mWindowAnimationStyle.activityExitAnimation = R.anim.bottom_dialog_out;
        PictureSelectorStyle pictureSelectorStyle = new PictureSelectorStyle();
        pictureSelectorStyle.setWindowAnimationStyle(mWindowAnimationStyle);
        int animationMode = AnimationType.SLIDE_IN_BOTTOM_ANIMATION;
        PictureSelector.create(activity)
                .openGallery(SelectMimeType.ofImage())
                .setImageEngine(GlideEngine.createGlideEngine())
                .setRecyclerAnimationMode(animationMode)
                .setSelectorUIStyle(pictureSelectorStyle)
                .isMaxSelectEnabledMask(false)
                .setMaxSelectNum(max)
                .setMinSelectNum(1)
                .setImageSpanCount(4)
                .isEmptyResultReturn(false)
                .setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
                .isOriginalControl(false)
                .setSelectionMode(max == 1 ? SelectModeConfig.SINGLE : SelectModeConfig.MULTIPLE)
                .isPreviewImage(true)
                .isPreviewVideo(true)
                .isDisplayCamera(false)
                .setCameraImageFormat(PictureMimeType.JPEG)
                .setCameraVideoFormat(PictureMimeType.MP4)
                .isGif(false)
                .isOpenClickSound(false)
                .forResult(request);
    }
}
